
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Tables"
clear
log using TableA4.txt, text replace 

***First-stage results adding returns for European Indicaes and Industry Portfolios
clear
clear all
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Data"
use LPSU_MainSample_Sep2024, replace
set matsize 10000
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Tables"

***Set of fixed effects
egen sic1year=group(sic1 year)
qui tabulate sic1year, generate(dsic1year)
egen month_post= group(month post)
qui tabulate month_post, generate(dmonth)
qui tabulate year_around_ipo, generate(deventyear) 

set more off
qui xtivreg2 wroa (IPO=instrument) deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth* , fe first cluster(id) partial(deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*)
gen sample_IV=e(sample) 
keep if sample_IV==1
**Dropping firms for which ROA only has one observation
bysort id: egen count=count(year)
drop if count==1 

****Stoxx returns
set more off
eststo: qui xtreg IPO instrument inst_stoxx deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe cluster(id) 
outreg2 using Table_oth_ret, keep(instrument inst_stoxx) sortvar(instrument inst_stoxx) tex(frag) word bdec(3) nocons label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes, IPO month x Post FE, Yes, Regression, First stage)  replace
****FTSE returns
set more off
eststo: qui xtreg IPO instrument inst_ftse deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe cluster(id) 
outreg2 using Table_oth_ret, keep(instrument inst_stoxx inst_ftse) sortvar(instrument inst_stoxx inst_ftse) tex(frag) word bdec(3) nocons label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes, IPO month x Post FE, Yes, Regression, First stage)  
****MSCI returns
set more off
eststo: qui xtreg IPO instrument inst_msci deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe cluster(id) 
outreg2 using Table_oth_ret, keep(instrument inst_stoxx inst_ftse inst_msci) sortvar(instrument inst_stoxx inst_ftse inst_msci) tex(frag) word bdec(3) nocons label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes, IPO month x Post FE, Yes, Regression, First stage)   
***Industry returns
set more off
eststo: qui xtreg IPO instrument instrument_pos_ind_ret3 deventyear2 deventyear3 deventyear4 deventyear5 dsic1year* dmonth*, fe cluster(id) 
outreg2 using Table_oth_ret, keep(instrument inst_stoxx inst_ftse inst_msci instrument_pos_ind_ret3) sortvar(instrument inst_stoxx inst_ftse inst_msci instrument_pos_ind_ret3) tex(frag) word bdec(3) nocons label ///
 addtext(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes, IPO month x Post FE, Yes, Regression, First stage)   

esttab,   keep(instrument inst_stoxx inst_ftse inst_msci instrument_pos_ind_ret3) order(instrument inst_stoxx inst_ftse inst_msci instrument_pos_ind_ret3) label se b(%9.3f) se(%9.3f) r2 star(* 0.1 ** 0.05 *** 0.01) addnotes(Firm FE, Yes, Event year FE, Yes, SIC x calendar year FE, Yes, IPO month x Post FE, Yes) 
 
eststo clear   
 
cd "C:\Users\sertsios\Dropbox\LPSU replication package RFS\Replication\Log files\Appendix Tables"
log close     
